package dormouse.vfs.metadata;

import java.io.IOException;
import java.util.Map;

import org.apache.commons.vfs2.FileObject;
import org.biogroovy.io.PDFArticleSerializer;
import org.biogroovy.models.Article;

/**
 * This class reads PDF metadata.
 */
public class PDFMetadataReader extends AbstractMetaDataReader implements
		IMetadataReader {

	/** Constructor */
	public PDFMetadataReader() {
		setFileExtensions(new String[] { "pdf" });
	}

	@Override
	public Map<String, String> getMetadata(FileObject file) throws IOException {
		
		PDFArticleSerializer serializer = new PDFArticleSerializer();

		
		Article article = serializer.readMetadata(file.getContent().getInputStream());
		
		metadata.put("title", article.getTitle());
		metadata.put("authors", article.getAuthorsAsString());
		metadata.put("pubmedId",article.getPubmedId());

		return this.metadata;
	}

}
